package ch.zbw.pra.sysventory.ui.gui.panels.overviewandsearchpanel.subpanels.detailPanel;

import java.awt.BorderLayout;

import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JScrollPane;

import ch.zbw.pra.sysventory.domain.factories.FileGenerator;
import ch.zbw.pra.sysventory.domain.factories.FileGenerator.FileType;
import ch.zbw.pra.sysventory.domain.model.Computer;
import ch.zbw.pra.sysventory.ui.gui.utilities.GuiLayout;

public class ComputerDetailViewDialog extends JDialog {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4998849719054542956L;
	private DetailPanel detailPanel;
	private JScrollPane scrollPane;

	public ComputerDetailViewDialog(Computer computer) {
		super();
		this.detailPanel = new DetailPanel(computer);
		this.scrollPane = new JScrollPane(this.detailPanel);

		init();
	}

	public void init() {
		try {
			this.setIconImage(new ImageIcon(new FileGenerator().getFile(FileType.ICON_PGS).getAbsolutePath()).getImage());
		} catch (Exception e) {
			System.out.println("Bild laden fehlgeschlagen");
		}

		this.scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		this.scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
		this.add(this.scrollPane, BorderLayout.CENTER);
		this.pack();
		GuiLayout.centerWindow(this);
		this.setVisible(true);
	}

}
